package school;

public class Student {
    private String id;
    private String name;
    private String gender;
    private Course course;

    public Student(String id, String name, String gender) {
        this.id = id;
        this.name = name;
        this.gender = gender;
    }

    public void selectCourse(Course course) {
        this.course = course;
    }

    public void dropCourse() {
        this.course = null;
    }

    public Course getCourse() {
        return course;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void printCourseTable() {
        if (course != null) {
            System.out.println("学生编号：" + id + "，姓名：" + name);
            System.out.println("课程名称：" + course.getName() + "，上课地点：" + course.getLocation() + "，时间：" + course.getTime() + "，授课教师：" + course.getTeacher().getName());
        } else {
            System.out.println("学生 " + name + " 暂未选课");
        }
    }

    @Override
    public String toString() {
        return "学生编号：" + id + "，姓名：" + name + "，性别：" + gender + "，所选课程：" + (course != null? course.getName() : "无");
    }
}